package com.leetcode.LC;

public class LC1021 {
    public String removeOuterParentheses(String S) {

        StringBuilder builder = new StringBuilder();
        int level = 0;
        for (char c : S.toCharArray()) {
            if (c == ')') --level;
            if (level >= 1) builder.append(c);
            if (c == '(') ++level;
        }
        return builder.toString();
    }
}
/*
                    作者：huaouo
                    链接：https://leetcode-cn.com/problems/remove-outermost-parentheses/solution/jian-ji-de-java-shi-xian-by-huaouo/
                    来源：力扣（LeetCode）
                    著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。
                    */
